package com.zlzxm.sorting.ui.fragment

import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.viewbinding.ViewBinding
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.listener.OnItemClickListener
import com.zlzxm.sorting.databinding.FmPrintBinding
import com.zlzxm.sorting.ui.adapter.AdapterPrintDevice
import com.zlzxm.sorting.ui.adapter.entity.EntivityPrintDevice
import com.zlzxm.sorting.util.ui.manager.AbsFmBase

class FmSettingPrint : AbsFmBase(), OnItemClickListener {

    val binding by  lazy {

        FmPrintBinding.inflate(layoutInflater)
    }

    val adapter = AdapterPrintDevice()

    override fun initBinding(): ViewBinding? {

        return  binding
    }

    override fun initViewModel() {
    }

    override fun initView() {

        binding.rv.layoutManager = LinearLayoutManager(requireContext())
        binding.rv.adapter = adapter
        adapter.setOnItemClickListener(this)
    }

    override fun initData() {

        val list = mutableListOf<EntivityPrintDevice>()
        list.add(EntivityPrintDevice("1","HRPT",true))
        list.add(EntivityPrintDevice("1","HRPT"))
        list.add(EntivityPrintDevice("1","HRPT"))
        list.add(EntivityPrintDevice("1","HRPT"))

        adapter.setNewInstance(list)
    }

    override fun onItemClick(adapter: BaseQuickAdapter<*, *>, view: View, position: Int) {
        this.adapter.selectPosition = position
    }
}